package com.liu.springboot.study.filter;

import com.liu.springboot.study.enums.ResultEnum;
import com.liu.springboot.study.exception.StudyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.ComponentScan;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * Created by LIUJC9 on 2017/12/6.
 */
@WebFilter(filterName = "studentFilter", urlPatterns = "/*")
public class StudentFilter implements Filter{
    private final static Logger logger = LoggerFactory.getLogger(StudentFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        logger.info("############ doFilter start in StudentFilter");
        if(true){
            throw new RuntimeException("aaaa");
        }
        filterChain.doFilter(servletRequest,servletResponse);
        logger.info("############ doFilter after in StudentFilter");
    }

    @Override
    public void destroy() {

    }
}
